package com.gcd.skymallorderitemapi.service;

import com.situ.utils.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

//调用商品微服务
@FeignClient(value="skymall-gateway",contextId = "ProductFeignServiceNormal")
public interface ProductFeignService {
    //根据id查询商品
    @GetMapping("/product-api/api/v1/products/id/{id}")
    ResponseEntity<JsonResult<?>> getById(@PathVariable Integer id);


    /**
     * 扣减库存
     * @param productId 商品id
     * @param delta 扣减数量
     * @return 是否扣减成功
     */
    @PostMapping("/product-api/api/v1/products/decrementStock/id/{productId}/delta/{delta}")
    ResponseEntity<JsonResult<Boolean>> decrementStock(@PathVariable Integer productId,
                                                 @PathVariable int delta);

}
